from typing import List


def modifiedMatrix(matrix: List[List[int]]) -> List[List[int]]:
    for j in range(len(matrix[0])):
        mx = max(row[j] for row in matrix)
        for row in matrix:
            if row[j] == -1:
                row[j] = mx
    return matrix

def modifiedMatrix1(matrix: List[List[int]]) -> List[List[int]]:
    m = len(matrix)
    n = len(matrix[0])
    answer = [[0] * n for _ in range(m)]
    for i in range(m):
        for j in range(n):
            if matrix[i][j] != -1:
                answer[i][j] = matrix[i][j]
            else:
                max_val = -1
                for k in range(m):
                    max_val = max(max_val,matrix[k][j])
                answer[i][j] = max_val
    return answer

